//
//  CoinAssetCell.m
//  AppleMarket
//
//  Created by yangy on 01/11/2018.
//  Copyright © 2018 szgsy. All rights reserved.
//

#import "CoinAssetCell.h"
// model
#import "CoinAssetModel.h"

@interface CoinAssetCell()
@property (nonatomic, strong) UILabel *nameLabel;
@property (nonatomic, strong) UILabel *enableLabel;
@property (nonatomic, strong) UILabel *disableLabel;
@end

@implementation CoinAssetCell
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        [self initView];
    }
    return self;
}

- (void) updateWithModel:(CoinAssetModel*) model
{
    _nameLabel.text = model.Unit;
    _enableLabel.text = [NSString stringWithFormat:@"%lf",model.Available];
    _disableLabel.text = [NSString stringWithFormat:@"%lf",model.Frozen];
}

- (void) initView
{
    [self.contentView addSubview:self.nameLabel];
    [self.contentView addSubview:self.enableLabel];
    [self.contentView addSubview:self.disableLabel];
    [self setLayoutSubviews];
}

- (void) setLayoutSubviews
{
    [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.contentView);
        make.left.mas_equalTo(self.contentView).offset(15);
    }];
    
    [_enableLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.contentView.mas_centerX).offset(-50);
        make.centerY.mas_equalTo(self.contentView);
    }];
    
    [_disableLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(self.contentView).offset(-15);
        make.centerY.mas_equalTo(self.contentView);
    }];
}

- (UILabel *)nameLabel
{
    if(!_nameLabel){
        _nameLabel = [UILabel cm_labelWithText:@"" font:kFontBold(16) textColor:kColorWithHex(0x0E304C)];
    }
    return _nameLabel;
}
- (UILabel *)enableLabel
{
    if(!_enableLabel){
        _enableLabel = [UILabel cm_labelWithText:@"" font:kFontBold(16) textColor:kColorWithHex(0x0E304C)];
    }
    return _enableLabel;
}
- (UILabel *)disableLabel
{
    if(!_disableLabel){
        _disableLabel = [UILabel cm_labelWithText:@"" font:kFontBold(16) textColor:kColorWithHex(0xB5C0CB) textAlign:NSTextAlignmentRight];
    }
    return _disableLabel;
}
@end
